package com.ecnu.web.controller.tool;

import com.ecnu.common.core.domain.AjaxResult;
import com.ecnu.common.core.domain.entity.SysUser;
import com.ecnu.common.core.domain.model.LoginUser;
import com.ecnu.system.domain.dto.incubation.IncubationFactoryDTO;
import com.ecnu.system.service.IIncubationFactoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = "API接口")
@RestController
@RequestMapping("/api")
public class APIController {

    @Autowired
    private IIncubationFactoryService incubationFactoryService;

    @ApiOperation(value = "保存")
    @PostMapping("/edit")
//    @PreAuthorize("@ss.hasPermi('incubation:edit')")
    public AjaxResult save(@Valid @RequestBody IncubationFactoryDTO dto) {
//        LoginUser loginUser = getLoginUser();
        LoginUser loginUser = new LoginUser();
        loginUser.setUserId(3L);
        dto.setSource("AI解析");
        return incubationFactoryService.edit(dto, loginUser);
    }
}
